package day05;
import java.util.Scanner;
import java.util.Random;
public class MethodDemo2 {
    public static void main(String[] args) {
        /*int s=sum(4,5);
        System.out.println("sum="+s);
        int a=3,b=7;
        int c=sum(a,b);
        System.out.println("sum="+c);
        System.out.println("----------------------------------------------");
        int[] d=generateArray();
        System.out.println("数组的长度："+d.length);
        for (int i=0;i<d.length;i++){
            System.out.println(d[i]);
        }
        int[] e= generateArray();
        for (int i =0;i<e.length;i++){
            System.out.println(e[i]);
        }*/
        Scanner scan = new Scanner(System.in);

        System.out.println("输入你要多大的数组：");
        int len = scan.nextInt();
        System.out.println("输入随机数的范围你要的范围(包括0到这个数)：");
        int max = scan.nextInt();
        int[] a=generateArray(len,max);
        for (int i=0;i<a.length;i++){
            System.out.println(a[i]);
        }
    }
    public static int sum(int a,int b){
        int sum=0;
        sum=a+b;
        return sum;
    }
    public static int[] generateArray(int len,int max){
        Random rand = new Random();
        int[] a=new int[len];
        for (int i=0;i<a.length;i++){
//            a[i]= (int)(Math.random()*(max+1));
            a[i] =rand.nextInt(max+1);//0-max+1
        }
        return a;
    }
}
